package dp.mobile.eden;

import dp.mobile.system.SoundManager;
import dp.mobile.system.Utilities;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

public class SplashScreenAct extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.splash);
		Thread timer = new Thread() {
			@Override
			public void run() {
				long startTime = System.currentTimeMillis();
				

				Log.d("Splash", "doing initialize apps");
				Utilities.initializeApps(SplashScreenAct.this.getApplicationContext());
				Log.d("Splash", "done initialize apps");
				
				long now = System.currentTimeMillis();
				if (now - startTime < Utilities.SPLASH_TIME){
					try {
						sleep(Utilities.SPLASH_TIME - (now - startTime));
					} catch (InterruptedException iEx){
						
					}
				}
				
				SplashScreenAct.this.finish();
				//startActivity(new Intent(SplashScreenAct.this.getApplicationContext(), GameAct.class));
				startActivity(new Intent(SplashScreenAct.this.getApplicationContext(), MainMenuAct.class));
			}
		};
	
		timer.start();
	}
	
	@Override
	public void onBackPressed() {
		super.onBackPressed();
		SoundManager.instance(getBaseContext()).stopAllSound();
		SoundManager.instance(getBaseContext()).releasePool();
	}
}
